package test;

import com.alibaba.fastjson.JSONObject;
import com.zimmor.hq.service.impl.MyDllInterfaceImpl;
import com.zimmor.hq.util.CommonUtil;
import com.zimmor.hq.util.EomsgUtil;
import com.zimmor.hq.util.OkHttpUtil;
import jdk.internal.org.objectweb.asm.tree.analysis.Value;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.junit.Test;

import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

public class Demo {
    public static void main(String[] args) {
        /**
         * 0223 01:27
         * * “{"errorCode":"0","randstr":"@iBt","ticket":"t03z2y0qI-aPmlDi8-jRd0OvVrNEqmpmY7WheWCbz568paDoabBMCgapuDUzEc1wAJytJuLx21A8e1C_36WkwoJxtZh2dO5vbCCzQRrFl3FF-AuHxtqTWaa25HQo-O6H3cpOYhm0oDmDNA*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@Ijk","ticket":"t037IZILob-NKVgEQ4w3qNzKGR9jsO4URaBqwlnom2R4R0y4W_g4xtxChO19WXqhfivSnGm1Vz_W46KeStw1JX--hZbPmHMut4K9I9yF-KpOJu7kfb_77K6q-Fznx3kuNb3DOqoKbJib7I*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@mVF","ticket":"t036z79wyLoiVMyfnFeTlWAMfnnfNZZDE2WII1rpQH4GdSlWtYdeO1xZQQ096HfmrYLufnwAe9nnJ2qiACa-5xqpTY9x1mzARiBS6X6P4GMNxWs2ruR7XTxFE9eO3aLjRrYUku5dtyyF5k*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@1Id","ticket":"t03-zJuaKXVL9BBuhH_UlBPBlS5U57YXjM8xSQg-H4ZtuT14WAkdeA4yWXeKo1fHkEqpRaH8TQ3OhTXQNTYo0-na_af-jXad4fdp8rJgzzP87G_kGfc0zHy-rItmGZveNNHEHB-6M3UQuE*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@Jec","ticket":"t0365spJ0hx6ODfgzGZwf7lBFsnmPbDH3743E6h2l1gdDxvcH6rWoCfDS-SQrlIcvrl-_9gY6q4OvH1SJe6lRroc063nliTZDbibJxEbrlavSob0SO4eI13y7sEDXR-WXR2zj4K8gI-dEo*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@Dde","ticket":"t03TtIUk5kN66pRZsi2mswfie9Cr45cRPdntqymCvQT4wySiwJy-NYDKJdfiVkDOGlfREWxSsx2Jkl_6tLhlJRDTVIGHkUC4JL-I5g8zwIC0K3hFCdyRm9HtPNJAQeuLzx2PCOVG8awWbY*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@QMl","ticket":"t03-oKB6QDUwqZTQ49cU8qHUCvNShSU9kgBla1ChhVizFIbGo0ZJk57knJRq4ttiN72bjuJ62tlYm1kf4EJFtutHwsnXHEwJGl9askIYJ9Rs-F1NsSmXjUPxxwM7rEWNqFfMLjKuozDlJo*","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@oDB","ticket":"t03IVgoa1nuybSOI2QkvxSwYPQJGd_oVAqblsIkqgi4QhW142XvBhBdb6tiSw3F-9-sRPBVlOM3_vvEVSMiO2u09ay4V9c9Ve13LxDGW6LaH2MsMKGxCc16AfomxoTpdLOR0xOn3CO7TVg*","errMessage":"","sess":""}”
         */

        /**
         * 滑动
         * * “{"errorCode":"0","randstr":"@o3U","ticket":"tr03QZhacCRmzvhfIarKyqLmj5uoXe2PbfxscoFMm4iUtMw6oYozacIcRf5bFqK3apnt-S7sNo-6NDtVIe24QRVZ0fbwb6ZUSKhJCKVVdoFv2dAuok57VWAs3KFKUIPrlVtb","traceId":"","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@T7R","ticket":"tr03ULPhgrC1C5SsSDcRY1jLeEHpt2VLOLv59WDf5kompwok0v8uSN1TLWLmz_AxoPK7Uj4q0Eb55XsKUbAccaj9w-gnsvrp8YbLJ0jRbHC1Rh8LZuOAJH6tF_AVsC1BEYU0","traceId":"","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@4xe","ticket":"tr03pnHd9nSUHjI_gGqLyK9wpUClWXe2yiTLuw0wtJPD3_c9__rD-n98v7x7HE2hHs6CdVB8jKAEilS-u4VFLuU6KzY4ziJVoQBi4Hjh6HgXkU7z7WEyZQWVcXpaIhW_VmT0","traceId":"","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@PNL","ticket":"tr036vGE2DPerhyC_QaEdAmiE20_SW826SQgSjdzaVq0GTGWdb0thlGXFew4omyaPXEC2-HawJ7Gnu9DzCpUBAiU4QXQt_ChwQbWRCmvmBop3oT3c3-FzmRGOS9WAeN-ChIs","traceId":"","errMessage":"","sess":""}”
         * * “{"errorCode":"0","randstr":"@pUg","ticket":"tr03POZnT42MA8q0axZ-k_T7LYaMQprSWLxvHuHYymj2O5rvagNavsvXYeel5MPB_bHRALOy9ANj0mbmugeg4Z3xvZrQYItxr_DNnyHu52x8u-ENYZeQoJov_f4VkIIBUSur","traceId":"","errMessage":"","sess":""}”
         */

        //15629471151/0.35/【北京环球度假区】验证码354890，5分钟内有效。尊敬的用户156****1151，您正通过短信验证方式登录，如非本人操作请忽略

//        1193776794   13593117257
        String token = "b4b439fc497647938b63e4c21b925f04";
//        String token = EomsgUtil.login("1193776794", "13593117257");
//        System.out.println("token = " + token);
//        String leftAmount = EomsgUtil.leftAmount(token);
//        System.out.println("leftAmount = " + leftAmount);
//        String phone = EomsgUtil.getPhone(token);
//        System.out.println("phone = " + phone);
        String phone = "15629471151";
        String msg = EomsgUtil.getMsg(token, phone, "北京环球度假区");
        System.out.println("msg = " + msg);
//        String release = EomsgUtil.release(token, phone);
//        System.out.println("release = " + release);
////        String send = EomsgUtil.send(token, phone, "15094057149", "测试");
////        System.out.println("send = " + send);
//        String queryUsed = EomsgUtil.queryUsed(token);
//        System.out.println("queryUsed = " + queryUsed);
//        String block = EomsgUtil.block(token, phone);
//        System.out.println("block = " + block);


    }

    @Test
    public void fun1() {
        String url = "http://47.111.146.48:8091/backend-service/test/pushBookOrder";

                // 创建代理对象
                Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("220.189.78.117", 64256));

                // 创建 OkHttpClient.Builder 对象，并配置代理
                OkHttpClient.Builder builder = new OkHttpClient.Builder()
                        .proxy(proxy);

                OkHttpClient client = builder.build();

                // 创建请求
                Request request = new Request.Builder()
                        .url(url)
                        .build();

                // 发送请求
                try (Response response = client.newCall(request).execute()) {
                    // 处理响应
                    if (response.isSuccessful()) {
                        String responseBody = response.body().string();
                        System.out.println("Response: " + responseBody);
                    } else {
                        System.out.println("Error: " + response.code() + " " + response.message());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
    }

    @Test
    public void fun2() {
        String url = "http://47.111.146.48:8091/backend-service/test/pushBookOrder";
        OkHttpUtil.setProxy("220.189.78.117", 64256);
        String s = OkHttpUtil.get(url);
        System.out.println("s = " + s);
    }

    @Test
    public void fun3() {
        String url = "https://m.laseglobal.com/api/backend-service/long_bridge/full_list?sortType=MORE&pageSize=200";
        Map header = new HashMap<>();
        header.put("authorization", "iu39Mc8o9cZy8yVcjxSoov61czbwVmdgv8gB");
        header.put("language", "US");
        header.put("content-type", "application/json");
        OkHttpUtil.setProxy("1.82.107.192", 64256);
        String s = OkHttpUtil.get(url, header);
        System.out.println("s = " + s);
    }

    @Test
    public void fun4() {
        String msg = "15629471151/0.35/【北京环球度假区】验证码354890，5分钟内有效。尊敬的用户156****1151，您正通过短信验证方式登录，如非本人操作请忽略";
        String s = CommonUtil.extractVerificationCode(msg);
        System.out.println("s = " + s);
    }

    @Test
    public void fun5() {
        String jsonStr = "{\"ret\":0,\"msg\":\"OK\",\"errorcode\":0,\"data\":{\"uid\":\"65d962a1d5317d1be673d6ab\",\"ciam_id\":\"4087160357524232702\",\"nickname\":\"15629471151\",\"avatar\":{\"id\":\"5f83c80c3eb82b15f645a533\",\"url\":\"https://cdn.app.universalbeijingresort.com/content/cce879d1b6c621d4dc23b6ff5e2f9cb5/Stuart.png\",\"theme_color\":[254,246,235]},\"token\":\"eyJlIjoxNzExMzM3Mzc3LCJkIjoiYjI0YTBlNzcxYzRkMGRiNmQzMmM3OTczZTM3YjhjODUiLCJ1IjoiZDlkZjNkNDk5MTMwMjZjNmNlYmM4NTU0MjEyYWRmYzIzNTgyODM5Mjg3NjNjMjYzNTliYjc3Y2MyM2M4ZjdlYiIsInAiOjAsInQiOiJhcHAiLCJvIjoiQW5kcm9pZCJ9.59609c79c75fe9a066549b8be7e6f019e2131614faa3aeb0fe1fec73d7e3ad07\",\"mobile\":\"15629471151\",\"email\":\"\",\"is_new\":true,\"is_preview_app\":0}}";
        JSONObject jsonObject = new JSONObject();
        String msg = CommonUtil.getJsonValue(CommonUtil.strTOJSONObject(jsonStr), "msg");
        System.out.println("msg = " + msg);
    }


}
